<!DOCTYPE html>
<html>
<include file="Public:header" />
<link href="__ACSS__/dialog.css" rel="stylesheet">
<link href="__ACSS__/plugins/validform/validform.css" rel="stylesheet">
<style>
	.form-control{ padding-left:5px;}
	.upload-warp{ position:relative;}
	.upload-btn{ position:absolute; top:0; right:0; border-radius:0;}
	
	.purchase-box{ width:90%;}
	.purchase-box span{ border:1px solid #ddd; padding:3px 10px; border-radius:4px; float:left; background:#fff; font-size:15px; position:relative; cursor:pointer; margin:0 10px 10px 0;}
	.purchase-box span i{ margin-left:8px; color:#888;}
	.purchase-box span:hover{ border:1px solid #999; background:#eee;}
</style>
  <body>
	  <div class="wrapper wrapper-content animated fadeInRight">
	  	<form role="form" class="form" action="__URL__/insert">
			<input type="hidden" name="flag" value="1">
			<input type="hidden" name="create_time" value="<php>echo time();</php>">
			<div class="form-group">
				<label class="col-sm-2 control-label">发送对象：</label>
				<div class="col-sm-10">
					<select name="is_all" datatype="*"class="form-control">
						<option value="2">全体会员</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">类型：</label>
				<div class="col-sm-10">
					<select name="type" datatype="*" placeholder="类型" class="form-control" id="type">
						<option value="2">活动消息</option>
						<option value="3">商品消息</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">消息：</label>
				<div class="col-sm-10">
					<textarea datatype="*" name="message" placeholder="消息" class="form-control"></textarea>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">选择活动&商品：</label>
				<div class="col-sm-10">
					<div class="upload-warp">
						<div class="purchase-box">
							
						</div>
						<button type="button" class="btn btn-primary upload-btn select-btn">&nbsp;选择&nbsp;</button>
					</div>
					<div class="clearfix"></div>
					<input type="hidden" datatype="*" id="ambulance" name="ambulance"/>
				</div>
				<div class="clearfix"></div>
			</div>
			<div role="alert" class="alert alert-info" style="line-height:24px; text-align:center"><strong><font style="color:red">消息提交后将立即发送，请慎重提交！</font></strong></div>
			<br/>
			<div class="clearfix">
				<button type="submit" id="submit" class="btn btn-success btn-block">提交</button>
				<button type="reset" id="reset2" class="btn btn-success btn-block hidden">重置</button>
			</div>
		</form>
	  </div>
  </body>
<!-- 全局js -->
<include file="Public:foot" />
<script src="__AJSPLUGINS__/validform/Validform_v5.3.2_min.js"></script>
<script>
$(function(){
	$("#reset2").click();
	var index = parent.layer.getFrameIndex(window.name);
	var form = $(".form").Validform({
		tiptype:4,
		ajaxPost:true,
		callback:function(data){
			if(data.status == 1) {
				window.parent.layer.msg(data.info);
				window.parent.$('#table_list').trigger("reloadGrid");
			}else{
				window.parent.layer.msg(data.info);
			}
			parent.layer.close(index);
		}
	});
	$(".select-btn").click(function() {
		var type = $("#type").find("option:selected").val();
		if(type == 2){
			layerDialog("选择活动&商品",'__URL__/activity',"90%","90%",true);
		}else if(type == 3){
			layerDialog("选择活动&商品",'__URL__/product',"90%","90%",true);
		}	
	})
})
function getPurchase(l){
	var html = "";
	var ids = "";
	var item = l.split("_");
	html += '<span ref="'+ item[0] +'" onclick="checkDel(this)">'+ item[1] +'<i class="fa fa-times"></i></span>';
	ids += item[0];
	$("#ambulance").val(ids);
	$(".purchase-box").html(html);
}
function checkDel(t){
	var ids = "";
	$(t).remove();
	$("#ambulance").val("");
}
</script>
</html>